﻿app.service("DanTocSrv", function ($http) {
    var path = "/api/dantoc/";
    //GetAll
    this.GetAll = function () {
        return $http.get(path + "getall");
    };

    // GetById
    this.getBook = function (bookId) {
        var response = $http({
            method: "post",
            url: "Home/GetBookById",
            params: {
                id: JSON.stringify(bookId)
            }
        });
        return response;
    }

    // Save(Add and Update) 
    this.Save = function (obj) {
        var response = $http({
            method: "post",
            url: path + "save",
            data: JSON.stringify(obj),
            dataType: "json"
        });
        return response;
    }

    //Delete
    this.Delete = function (id) {
        var response = $http({
            method: "post",
            url: path + "delete/" + id
        });
        return response;
    }

    //Delete
    this.CheckDuplicateCode = function (code) {
        var response = $http({
            method: "post",
            url: path + "checkduplicatecode/" + code
        });
        return response;
    }
});